package com.example.big_job;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

import com.example.big_job.Adapter.MainAdapter;
import com.example.big_job.Slide.SlideMenu;

import java.util.ArrayList;
import java.util.List;

public class MeauActivity extends AppCompatActivity {
    private ImageView i_head;
    private SlideMenu slideMenu;
    private RecyclerView rv;
    private List<Integer> datas;
    private ImageView daodian;
    private ImageView introduce;
    private ImageView dianping;
    private Button B_order;

    private Button B_tuichu;
    private Button B_kefu;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_meau);

        //找控件
        i_head=findViewById(R.id.iv_head);
        slideMenu=findViewById(R.id.slide);
        rv=findViewById(R.id.r1);
        daodian=findViewById(R.id.i_dd);
        B_order=findViewById(R.id.b_order);

        B_tuichu=findViewById(R.id.b_tuichu);
        B_kefu=findViewById(R.id.b_kefu);
        RecyclerView mRecyclerView = (RecyclerView) findViewById(R.id.r1);
        introduce=findViewById(R.id.i_jieshao);
        dianping=findViewById(R.id.comment);
        //监听
        introduce.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=null;
                intent=new Intent(MeauActivity.this, IntroduceActivity.class);
                startActivity(intent);
            }
        });
        dianping.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=null;
                intent=new Intent(MeauActivity.this, CommentActivity.class);
                startActivity(intent);
            }
        });
        B_order.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=null;
                intent=new Intent(MeauActivity.this, OrderActivity.class);
                startActivity(intent);
            }
        });

        B_tuichu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=null;
                intent=new Intent(MeauActivity.this, LoginActivity.class);
                startActivity(intent);
            }
        });
        B_kefu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=null;
                intent=new Intent(MeauActivity.this, AdviceActivity.class);
                startActivity(intent);
//                Toast.makeText(getApplicationContext(), "该功能尚未推出，敬请期待！", Toast.LENGTH_SHORT).show();
            }
        });

        //到店，跳转
        daodian.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=null;
                intent=new Intent(MeauActivity.this,StoreActivity.class);
                startActivity(intent);
            }
        });

        //初始化
        initData();


        //设置布局管理器
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.VERTICAL, false));
        //设置adapter

        MainAdapter myAdapter=new MainAdapter(this,datas);
        mRecyclerView.setAdapter(myAdapter);
        //设置默认属性



        //侧滑,点击
        i_head.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                slideMenu.switchMenu();
            }
        });
    }

    private void initData() {
        datas = new ArrayList<>();

        Resources res = getResources();
//        datas.add(0);
        datas.add(res.getIdentifier("g1", "drawable", getPackageName()));
        datas.add(res.getIdentifier("g2", "drawable", getPackageName()));
        datas.add(res.getIdentifier("g3", "drawable", getPackageName()));
        datas.add(res.getIdentifier("g4", "drawable", getPackageName()));
        datas.add(res.getIdentifier("g5", "drawable", getPackageName()));
        datas.add(res.getIdentifier("g6", "drawable", getPackageName()));
        datas.add(res.getIdentifier("g7", "drawable", getPackageName()));
        datas.add(res.getIdentifier("g8", "drawable", getPackageName()));


    }


}